package com.example.neusoft.ui_demo.recyclerview;

import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

import com.example.neusoft.ui_demo.MainActivity;
import com.example.neusoft.ui_demo.R;
import com.example.neusoft.ui_demo.beans.Dish;
import com.example.neusoft.ui_demo.beans.Result;
import com.example.neusoft.ui_demo.beans.Shop;
import com.example.neusoft.ui_demo.retrofitservice.RetrofitService;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.squareup.picasso.Picasso;

import java.io.IOException;
import java.util.List;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by neusoft on 2018/9/20.
 */

public class ItemViewHolder extends RecyclerView.ViewHolder {
    private View itemView;
    public ImageView imageView;
    public TextView textView1,textView2;
    private int id;
    public ItemViewHolder(View itemView,int id) {
        super(itemView);
        this.itemView = itemView;
        imageView = itemView.findViewById(R.id.imageView2);
        textView1 = itemView.findViewById(R.id.textView1);
        textView2 = itemView.findViewById(R.id.textView2);

        //http://172.24.10.175:8080/foodService/getShopById.do?shop_id=1


//        Retrofit retrofit = new Retrofit.Builder()
//                .baseUrl("http://172.17.7.95:8080/MenuAPItemDemo/")
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//        //2
//        RetrofitService retrofitService = retrofit.create(RetrofitService.class);
//        //3
//        Call<Result> dishCall
//                = retrofitService.getDish("1");
//        //4
//        dishCall.enqueue(new Callback<Result>() {
//            @Override
//            public void onResponse(Call<Result> call, Response<Result> response) {
////                List<Dish> dishes = response.body();
//                Result dish=response.body();
//                textView1.setText(dish.);
//                //                        new Gson().toJson(dishes,
////                        new TypeToken<List<Dish>>(){}.getType()));
//            }
//
//            @Override
//            public void onFailure(Call<Result> call, Throwable t) {
//
//                textView1.setText(t.getLocalizedMessage());
//
//            }
//        });
//        Retrofit retrofit = new Retrofit.Builder()
//                .baseUrl("http://172.17.7.95:8080/MenuAPIDemo/")
//                .addConverterFactory(GsonConverterFactory.create())
//                .build();
//        //2
//        RetrofitService retrofitService = retrofit.create(RetrofitService.class);
//        //3
//        Call<List<Dish>> dishCall
//                = retrofitService.getDishes();
//        //4
//        dishCall.enqueue(new Callback<List<Dish>>() {
//            @Override
//            public void onResponse(Call<List<Dish>> call, Response<List<Dish>> response) {
////                List<Dish> dishes = response.body();
//                List<Dish> dishes=response.body();
//                textView1.setText(new Gson().toJson(dishes,new TypeToken<List<Dish>>(){}.getType()));
//            }
//
//            @Override
//            public void onFailure(Call<List<Dish>> call, Throwable t) {
//
//                textView1.setText(t.getLocalizedMessage());
//
//            }
//        });


    }


}
